subroutine startup()

  ! Routine contains a lot of necessary but unsightly, largely
  ! preprocessor-based, checks that I'd prefer to keep out of main()

  use logs
  use myfiles
  use param_module
  implicit none
  integer*4 :: nargs,iargc,ierr

  ! Open a logfile for each process
  logunit = 6

  ! Say hello
  write(logunit,*)
  write(logunit,*)' --------------------------------------------------------------------------'
  write(logunit,*)' TraceUnique :: Rob Crain, CAS, Swinburne, January 2010'
  write(logunit,*)' --------------------------------------------------------------------------'
  write(logunit,*)
  call flush(logunit)

  ! Grab command line arguments
  nargs = iargc()
  if(nargs /= 1) call abort("usage: TraceUnique paramfile")
  call getarg(1,paramfile)

  ! Read param file
  open(10,file=trim(adjustl(paramfile)),form='formatted',status='old')
  read(10,*)indir
  read(10,*)outdir
  read(10,*)icdir
  read(10,*)icfile
  read(10,*)istart
  read(10,*)iend
  read(10,*)hdf5_ics
  close(10)
  
  if(hdf5_ics < 0 .or. hdf5_ics > 1) call abort(" -hdf5_ics flag must equal 0 or 1")

end subroutine startup
